import axios from 'axios';
import { Message } from 'view-design';
const $axios = axios.create();
$axios.interceptors.request.use(config => {
  config.headers.crctoken = window.sessionStorage.getItem('crctoken') || '';
  return config;
}, error => {
  return Promise.reject(error);
});

$axios.interceptors.response.use(response => {
  return response;
}, error => {
  Message.error(`${error.message}：${error.config.url}，请咨询管理员`)
  return Promise.resolve({
    data: {
      msg: '业务繁忙，请稍后重试',
      code: -1
    }
  });
});

export default $axios;
